<div class="page-title">

    <div class="title-env">
        <h1 class="title">代理积分规则管理</h1>
    </div>

    <div class="breadcrumb-env">

        <ol class="breadcrumb bc-1">
            <li>
                <a href="{:url('/')}"><i class="fa-home"></i>Home</a>
            </li>
            <li>

                <a href="{:url('district/index')}">District</a>
            </li>
            <li class="active">

                <strong>PointRule</strong>
            </li>
        </ol>

    </div>

</div>
<div class="panel panel-default">


    <div class="panel-body">
        <div class="btn-toolbar">
            <div class="btn-group focus-btn-group">
                <button onclick="addItem()" class="btn btn-default"><i class="el-plus"></i> 添加</button>
            </div>
        </div>
        <form cation="{:url('pointRule')}" method="post">
            <table class="table">
                <thead>
                    <tr><th>最少人数</th><th>最多人数</th><th>每个人积分</th><th>操作</th></tr>
                </thead>
                <tbody id="rule_table_tbody">
                    {volist name="rule_data" id="o"}
                    <tr>
                        <td><input type="number" class="form-control" name="min[]" value="{$o['min']}"></td>
                        <td><input type="number" class="form-control" name="max[]" value="{$o['max']}"></td>
                        <td><input type="number" class="form-control" name="point[]" value="{$o['point']}"></td>
                        <td><button class="btn btn-danger" onclick="$(this).parent().parent().remove()">删除</button></td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
            <button class="btn btn-success" type="submit">保存</button>
        </form>
    </div>
</div>

{$code=='err4'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 登录账号重复了
    </div>
</div>

':''}
{$code=='err4'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 该用户已是其他区的代理
    </div>
</div>

':''}
{$code=='err3'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 用户不存在
    </div>
</div>

':''}
{$code=='err1'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 修改失败
        .请重新添加
    </div>
</div>

':''}

{$code=='err2'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 缺少字段
    </div>
</div>

':''}
{$code=='success'?'
<div class="col-md-6">
    <div class="alert alert-success" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 保存成功 ！</strong>
    </div>
</div>

':''}
<script>
    setTimeout("$('#alert').fadeOut(1000)",2000)
</script>
<script type="text/javascript">
    function addItem(){
        str = '<tr><td><input type="number" class="form-control" name="min[]"></td><td><input type="number" class="form-control" name="max[]"></td><td><input type="number" class="form-control" name="point[]"></td><td><button class="btn btn-danger" onclick="$(this).parent().parent().remove()">删除</button></td></tr>';
        $('#rule_table_tbody').append(str);
    }
    function saveRule() {
        if(status == 2) {
            var loginname = $('#loginname').val();
            var password = $('#password').val();
            if(loginname == '' || password == '') {
                layer.msg('用户名和密码不能为空');
                return false;
            }
            if(!confirm('确定要通过吗？')) {
                return false;
            }
        } else if(status == 3) {
            var reason = $('#reason').val();
            if(reason == '') {
                layer.msg('拒绝原因不能为空');
                return false;
            }
            if(!confirm('确定要拒绝吗？')) {
                return false;
            }
        } else {
            return false;
        }
        $('#status').val(status);
        $('#form1').submit();
    }
</script>